<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    div{
        background-color: red;
    }
</style>
<body>
    <div id="box"></div>
    <script>
        //操作style属性操作元素样式
        //1,获取元素对象
        var box = document.querySelector('#box');
        //添加元素对象的样式width，height
        box.style.width = '100px';
        box.style.height = '100px';
        //修改元素对象的样式backgroundColor
        box.style.backgroundColor = 'yellow';
    </script>
</body>
</html>